package com.sjsoft.video;

import java.util.ArrayList;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

import com.sjsoft.Utils.networkUtility;
import com.sjsoft.application.chatVideoApp;
import com.sjsoft.chat.video.ListVideo;
import com.sjsoft.chat.video.PayMoney;
import com.sjsoft.chat.video.mainTab;
import com.sjsoft.payment.PayCard;
import com.sjsoft.payment.PaySms;
import com.sjsoft.webservice.UtilsJson;

public class LoadAmoutInfor extends AsyncTask<Void, Void, Void>{
	int resultRequest;	
	boolean isNetWork = true;
	private String Imei="";
	private String sVersion;
	
	chatVideoApp application;
	Context mContext;
	//Constructor
	private ProgressDialog pDlg = null;
	public LoadAmoutInfor(Context context) {
		application = (chatVideoApp)context.getApplicationContext();
		if(application != null)
		{
			Imei = application.sImei;
			sVersion = application.sVersion;
		}
		mContext = context;
		isNetWork = networkUtility.getInstance(context)
				.isNetworkAvailable();
	}
	
	
	@Override
	protected void onPreExecute() {
		super.onPreExecute();	
		//showProgressDialog(); 
	}
	
	private void showProgressDialog() {
		pDlg = new ProgressDialog(mContext);
		pDlg.setMessage("Đang gửi đến máy chủ...");
		pDlg.setProgressDrawable(mContext.getWallpaper());
		pDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		pDlg.setCancelable(false);
		pDlg.show();
	}

	@Override
	protected Void doInBackground(Void... params) {
		if (isNetWork) {
			String jSon = UtilsJson.ExpiredDate(sVersion, Imei);
			application.nTotalAmount = UtilsJson.getTotalAmount(jSon);
		} else {
		}
		return null;
	}

	@Override
	protected void onPostExecute(Void result) {
		super.onPostExecute(result);	
		if(pDlg != null)
			pDlg.dismiss();
	}
}

